package com.fbinggun.fbinggunutil.statistics;

import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.OfflinePlayer;


public class StatistPapi extends PlaceholderExpansion {
    @Override
    public  String getIdentifier() {
        return "PlayerInfo";
    }

    @Override
    public  String getAuthor() {
        return "FBinggun";
    }

    @Override
    public  String getVersion() {
        return "1.0";
    }
    StatistMain main;
    StatisticsAPI api;
    public StatistPapi( StatistMain main) {
        this.main = main;
        api=main.getStatApi();
    }

    //PlayerInfo_id 获取统计的值
    //PlayerInfo_id_ct 获取统计时间 long
    //PlayerInfo_id_fc 获取第一次统计时间 long
    //PlayerInfo_id_cts 获取统计时间 str
    //PlayerInfo_id_fcs 获取第一次统计时间 str
    @Override
    public String onRequest(OfflinePlayer player,  String params) {
    String[] args =params.split("_");
    if(args.length==1){
       return main.getStatApi().getPlaceholder(player,args[0]);
    }else {
        if(args.length==2){
            String id =args[0];
            if(args[1].equalsIgnoreCase("ct")){
                return String.valueOf(api.getClockTime(player,id ));
            }
            if(args[1].equalsIgnoreCase("fc")){
                return String.valueOf(api.getFirstClock(player,id ));
            }
            if(args[1].equalsIgnoreCase("cts")){
                return String.valueOf(api.getClockTimeStr(player,id ));
            }
            if(args[1].equalsIgnoreCase("fcs")){
                return String.valueOf(api.getFirstClockStr(player,id ));
            }
        }
    }
    return params;

    }
}
